Security News
PyPI Introduces Digital Attestations to Strengthen Python Package Security
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
@vue/reactivity
Advanced tools
The @vue/reactivity package is part of the Vue.js framework, designed to provide a standalone reactivity system that can be used outside of Vue components. It allows developers to create reactive objects and track changes to them, enabling the development of responsive applications. The package includes features such as reactive state, computed values, and watchers.
Creating reactive objects
This feature allows you to create a reactive object. Any changes to the object's properties will be tracked, making it useful for building responsive interfaces.
import { reactive } from '@vue/reactivity';
const state = reactive({ count: 0 });
Creating computed properties
Computed properties automatically calculate their value based on reactive state. They are recalculated only when their dependencies change, making them efficient.
import { computed } from '@vue/reactivity';
const count = reactive({ num: 1 });
const plusOne = computed(() => count.num + 1);
Watching for changes
The watch function allows you to execute a callback function whenever a specified reactive property changes, enabling you to respond to changes in the state.
import { watch } from '@vue/reactivity';
const state = reactive({ count: 0 });
watch(() => state.count, (newVal, oldVal) => {
console.log(`Count changed from ${oldVal} to ${newVal}`);
});
MobX is a state management library that also provides reactivity. It uses observables and actions to manage state changes. Compared to @vue/reactivity, MobX can be used with any framework and offers a more opinionated approach to state management.
Immer is designed to work with immutable state, making it easier to update complex state without mutating the original state. Unlike @vue/reactivity, which tracks changes to mutable objects, Immer uses a copy-on-write mechanism.
RxJS is a library for reactive programming using Observables. It allows you to compose asynchronous and event-based programs. While @vue/reactivity focuses on reactive state for UIs, RxJS provides a broader set of tools for handling asynchronous data streams.
This package is inlined into Global & Browser ESM builds of user-facing renderers (e.g. @vue/runtime-dom
), but also published as a package that can be used standalone. The standalone build should not be used alongside a pre-bundled build of a user-facing renderer, as they will have different internal storage for reactivity connections. A user-facing renderer should re-export all APIs from this package.
For full exposed APIs, see src/index.ts
.
The implementation of this module is inspired by the following prior art in the JavaScript ecosystem:
Array
, Map
, WeakMap
, Set
and WeakSet
.3.5.12 (2024-10-11)
ifNode
(#12131) (cde2c06), closes vuejs/language-tools#4911undefined
(#12055) (7ad289e), closes #12054this.$props
type does not include string
(#12123) (704173e), closes #12122FAQs
@vue/reactivity
The npm package @vue/reactivity receives a total of 1,551,038 weekly downloads. As such, @vue/reactivity popularity was classified as popular.
We found that @vue/reactivity demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.
Security News
GitHub removed 27 malicious pull requests attempting to inject harmful code across multiple open source repositories, in another round of low-effort attacks.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.